package com.etoak.controller;


import com.etoak.bean.Homestay;
import com.etoak.bean.HomestayVO;
import com.etoak.bean.Page;
import com.etoak.bean.ResultVo;
import com.etoak.service.HomestayService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@RequestMapping("/homestay")
public class HomestayController {

    @Resource
    private HomestayService service;

    @GetMapping
    public ResultVo select(Page page, HomestayVO homestayVO){
        return ResultVo.success().setData(service.select(page,homestayVO));
    }
    @PostMapping
    public ResultVo add(@RequestBody Homestay homestay){
        if(service.add(homestay)>0){
            return ResultVo.success();
        }
        return  ResultVo.error();
    }
    @PutMapping
    public ResultVo update(@RequestBody Homestay homestay){
        if(service.update(homestay)>0){
            return ResultVo.success();
        }
        return  ResultVo.error();
    }


    @DeleteMapping
    public ResultVo del(Integer id){
        if(service.del(id)>0){
            return ResultVo.success();
        }
        return  ResultVo.error();
    }

}
